package com.dwxt.pay.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.pay.service.ZFBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("/pay")
@RestController
public class ZFBPayController {
    @Autowired
    private ZFBService zfbService;

    /**
     * @param price
     * @param notifyUrl 异步通知链接
     * @param orderId
     * @param type    支付方式 1 app 2扫码
     * @return
     */
    @RequestMapping("/zfb")
    public BaseResult payWithZFB(@RequestBody Map<String, String> params) throws Exception {
        //String ip = request.getRemoteAddr();
        return zfbService.pay(params);
    }

    @RequestMapping("/zfb/query")
    public BaseResult queryPayResult(String orderId) throws Exception {
        return zfbService.queryPayResult(orderId);
    }

    @RequestMapping("/zfb/refund")
    public BaseResult refund(String orderId, Double price) throws Exception {
        return zfbService.refund(orderId, price);
    }
}
